<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--[if IE 6 ]><html class="ie6"><![endif]-->
<!--[if IE 7 ]><html class="ie7"><![endif]-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{config.webtitle}</title>
<meta content="{config.webkeyword}" name="keywords" />
<meta content="{config.webdescription}" name="description" />





  <!--css-->
<%template src="cssjs.html"%>
<!--/css-->

<link rel="stylesheet" type="text/css" href="<%templateskin%>/css/ui-lightness/jquery.ui.core.css">
<link rel="stylesheet" type="text/css" href="<%templateskin%>/css/ui-lightness/jquery.ui.theme.css">
<link rel="stylesheet" type="text/css" href="<%templateskin%>/css/ui-lightness/jquery.ui.datepicker.css">

</head>

<body>

<div class="wrapper">
  
  <!--Header-->
<%template src="_header.html"%>
<!--/Header-->
   
  
  <div id="page_modules">
    
    <div class="center_wrapper center_lineGreen clearfix">
      <div class="left_con_m">
        <div class="tile_left_m">
          <div class="tile_zh">订购您的排毒计划！</div>
          <div class="tile_en"><em class="black">Order</em><em class="darkGreen"> YOUR</em><em class="lightGreen">JUICEUP</em></div>
        </div>
        
        <div class="order_warp">
        
            <div class="order_step">
              <ul>
              <li class="selected">第一步：计划开始日期</li>
              <li>第二步：确认</li>
              <li>第三步：付款</li>
              </ul>
            </div>
            <div class="order_selected">
              <span class="tile">您当前选择的是</span>
              <span class="info"><em>{model.title}</em>{model.content}</span>
            </div>
            <div class="order_days">
              <span class="tile">选择清体计划理想天数：</span>
              <ul class="order_days_select">
                <li><a href="javascript:void(0);" onClick="test(1)" >1</a></li>
                <li><a href="javascript:void(0);"  class="selected" onClick="test(3)" >3</a></li>
           <!--     <li><a href="javascript:void(0);" onClick="test(5)" >5</a></li>
                <li><a href="javascript:void(0);" onclick="test(7)" >7</a></li>-->
              </ul>
            </div>
            
            <div class="order_time_start clearfix">
              <span class="tile">请选择排毒开始日期</span>
              <div class="order_time_Date">
                <div id="datepicker"></div>
              </div>
            </div> 
             
            <div class="order_time_week">
                <a class="previous" id="previousweek" onClick="previousWeek();">&lt;上一周</a>
                <span id="showdate"></span>
                <a class="next" onClick="nextWeek();">下一周&gt;</a>
            </div>
            <!--显示日期-->
            <div class="myOrderCalendarWarp">
              <div id="mytable" class="myOrderCalendar"></div>
            </div>
            
        </div>
        
      </div>
      <div class="right_con_m">
        <p class="hotLineRight">欢迎拨打<br />JuiceUp 客服热线：<br />400-082-5955</p>
        <div class="orderConf">
          <h5>确认您的订单：</h5>
          <div class="price">产品：¥ <span id="price"></span> RMB</div>
          <div class="shipping">运费：¥ 0 RMB</div>
          <div class="total">总价：¥ <span id="price1"></span> RMB</div>
          <div class="btn_next"><a href="javascript:void(0);" onclick="CartAdd(this, '{config.webpath}', 1, '<%linkurl("shopping","confirm")%>');">下一步</a></div>
        </div>
               <!--right-->
<%template src="right.html"%>
<!--/right-->
      </div>
    </div>
    
  </div>
 




 <script src="<%templateskin%>/js/jquery.ui.datepicker.js"></script>
<script src="<%templateskin%>/js/jquery.ui.datepicker-zh-TW.js"></script>

<script type="text/javascript" src="<%templateskin%>/js/cart1.js"></script>
  <script type="text/javascript" src="<%templateskin%>/js/json2.js"></script>  
  <script type="text/javascript">
		    var starti = 3;
		    var currDT;
		    var aryDay = new Array("日", "一", "二", "三", "四", "五", "六"); //显示星期  
		    var lastDay; //页面显示的最后一天
		    var firstDay; //页面显示的第一天
		    //初始化日期加载
		    function initDate(myDates) {
		        currDT = myDates;
		        tempDate = myDates;
		        minDatetime = new Date();
		        minDatetime.setDate(minDatetime.getDate() + 2);
		       
		        setcontent("a");
		        
		        //重新赋值
		        lastDay = getDays()[13]; //本周的最后一天
		        firstDay = getDays()[0]; //本周的第一天

		    }
		    //取得当前日期两周内的某天
		    function getWeek(i) {
		        var now = tempDate;
		        var n = now.getDay();
		        var start = new Date(tempDate);
		        n = n == 0 ? 7 : n;
		        start.setDate(now.getDate() - n + i); //取得一周内的第一天、第二天、第三天...
		        return start;
		    }

		    //取得当前日期两周内的14天
		    function getDays() {
		        var days = new Array();
		        for (var i = 0; i <= 14; i++) {
		            days[i - 1] = getWeek(i);
		        }
		        return days;
		    }

		    //取得下两周的日期数(共14天)
		    function getNextWeekDatas(ndt) {
		        var days = new Array();
		        for (var i = 1; i <= 14; i++) {
		            var dt = new Date(ndt);
		            days[i - 1] = getNextWeek(dt, i);
		        }
		        return days;
		    }
		 
		    //指定日期的下两周(后14天)
		    function getNextWeek(dt, i) {
		        var today = dt;
		        today.setDate(today.getDate() + i);
		        return today;
		    }


		    //取得上两周的日期数(共14天)
		    function getPreviousWeekDatas(ndt) {
		        var days = new Array();
		        for (var i = -14; i <= -1; i++) {
		            var dt = new Date(ndt);
		            days[14 + i] = getPreviousWeek(dt, i);
		        }
		        return days;
		    }

		    //指定日期的上两周(前14天)
		    function getPreviousWeek(dt, i) {
		        var today = dt;
		        today.setDate(today.getDate() + i);
		        return today;
		    }

		    //下两周
		    function nextWeek() {
		        currDT.setDate(currDT.getDate() + 14); //重设时间
		        setcontent("b");
		        firstDay = getNextWeekDatas(lastDay)[0]; //注意赋值顺序1
		        lastDay = getNextWeekDatas(lastDay)[13]; //注意赋值顺序2
		    }
		
		     Data = [];
           
		    var type = <%=category_id %>; //类别
            <%set DataTable goods_list=get_article_list("goods", category_id, page, "status=0", out totalcount, out pagelist, "goods_list", category_id, "__id__")%>
var plist=[<%loop dr goods_list%>{ "id": {dr[id]},"q": 1,"j":{dr[sell_price]}}<%if(dr__loop__id!=goods_list.Rows.Count)%>,<%/if%><%/foreach%>];
          
		    function setcontent(Days) {
		        if (Days == "a") {

                var order_amount=0;
		            var d = new Date(currDT);

		            Data.length = 0;
		            for (var j = 0; j < starti; j++) {

		                s = j == 0 ? 0 : 1;
 Data.push({ "id": j, g: [], "e": d.setDate(d.getDate() + s), "t": type ,"a":0,"s":0});
                       
		                for (var h = 0; h < plist.length; h++) {
		                    Data[j].g.push(plist[h]);
                            order_amount=Number(order_amount+plist[h].j);
		                }
		            }
                    $("#price").text(order_amount)
                    $("#price1").text(order_amount)
		        }
                
 
		        showdate.innerHTML = currDT.toLocaleDateString(); //显示日期  
		        //在表格中显示一周的日期  
		        var objTB = document.getElementById("mytable"); //取得表格对象
		        var dw = currDT.getDay(); //从Date对象返回一周中的某一天(0~6)
		        var tdDT; //日期
		        var $tr = $('<ul>');
		        $('#mytable').empty();
		        
		        for (var i = 0; i < 14; i++) {
		            if (Days == "a") {
		                tdDT = getDays()[i];

		            } else if (Days == "b") {
		                tdDT = getNextWeekDatas(lastDay)[i];
		            }
		            else {
		                tdDT = getPreviousWeekDatas(firstDay)[i];
		            }
		            if (i ==0) {
		                if (minDatetime - tdDT > 0 || minDatetime.Format("yyyy-MM-dd") == tdDT.Format("yyyy-MM-dd")) {
		                    $("#previousweek").hide();
		                }
		                else {
		                    $("#previousweek").show();
		                }
		            }
		            dw = tdDT.getDay(); //星期几

		            if (minDatetime - tdDT < 0 || minDatetime.Format("yyyy-MM-dd")==tdDT.Format("yyyy-MM-dd")) {


		                var itemst= jQuery.grep(
                Data, function (item, index) { return new Date(parseInt(item.e, 10)).Format("yyyy-MM-dd") == tdDT.Format("yyyy-MM-dd"); });
		                
		                if (itemst.length>0) {
 var $td = $('<li>').html('<div class="time"><span class="week">周'+aryDay[dw]+'</span><span class="day">'+(tdDT.getMonth()+1)+'/'+tdDT.getDate()+'</span></div>').addClass("selected");
 var $add=$('<div class="add"><img src="<%templateskin%>/images/date_bottle.png"><p></p></div>');
 $td.append($add);
                            
//                            "tdDT.getMonth() + 1 + "/" + tdDT.getDate() + "" + aryDay[dw] + "6瓶id:" + itemst[0].id);
		                }
		                else {
 var $td =$('<li>').html('<div class="time"><span class="week">周'+aryDay[dw]+'</span><span class="day">'+(tdDT.getMonth()+1)+'/'+tdDT.getDate()+'</span></div>');
 var $add=$('<div class="empty"></div>');
 $td.append($add);
		                }

		                //   

		                $tr.append($td);


		                //objTB.rows[0].cells[i].style.color = "red";//currDT突出显示  
		            }
		            else {
		              var $td =$('<li>').html('<div class="time"><span class="week">周'+aryDay[dw]+'</span><span class="day">'+(tdDT.getMonth()+1)+'/'+tdDT.getDate()+'</span></div>');
                       var $add=$('<div class="empty"></div>');
 $td.append($add);

 

		            }
                      $tr.append($td);
		        }
		        $("#mytable").append($tr);

		    }
		    Date.prototype.Format = function (fmt) { //author: meizz 
		        var o = {
		            "M+": this.getMonth() + 1, //月份 
		            "d+": this.getDate(), //日 
		            "h+": this.getHours(), //小时 
		            "m+": this.getMinutes(), //分 
		            "s+": this.getSeconds(), //秒 
		            "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
		            "S": this.getMilliseconds() //毫秒 
		        };
		        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
		        for (var k in o)
		            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
		        return fmt;
		    }
		    
		    //上一周
		    function previousWeek() {
		        currDT.setDate(currDT.getDate() - 14);
		        setcontent("c");
		        //重新赋值
		        lastDay = getPreviousWeekDatas(firstDay)[13]; //注意赋值顺序1
		        firstDay = getPreviousWeekDatas(firstDay)[0]; //注意赋值顺序2
		    }
</script>   
	<script  type="text/javascript">
	    $(function () {
	        var myDate = new Date();
	        myDate.setDate(myDate.getDate() + 2);
	        $("#datepicker").datepicker({ "minDate": myDate,
	            showOtherMonths: true,
	            selectOtherMonths: true,
	            onSelect: function (selectedDate) {
	                initDate(new Date(selectedDate));
	            }
	        });

	        initDate(myDate);
	    });
	    function test(v) {
	        starti = v;
	        initDate(currDT);
	    }
	</script>





     
 
<!--Footer-->
<%template src="_footer.html"%>
<!--/Footer-->
